<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

/*
    Class: ezpdo
    This library includes the gloabl EZPDO lib and sets up the epManacger
    instance.

    About EZPDO:
    EZPDO is a lightweight and easy-to-use persistence solution for PHP.
    
    - Works with existing code and database
    - Has a small runtime core to guarentee performance
    - Handles 1:N, and M:N relationships automatically
    - Provides a simple runtime API
    - Supports object query (EZOQL)

    http://ezpdo.net
    
    Installation:
    - Download the latest EZPDO release from <http://www.ezpdo.net/releases.php>.
    - Extract tarball to the <ci-ext.libs_path>.
    
*/
class ezpdo {

    /*
        Variable: _ci
        Holds an instance of the CI class
    */
    private $_ci;

    
    /*
        Contructor:
        Get an instance of the CI class, include the EZPDO runtime and setup
        config options
    */
    function __construct() {
        $this->_ci =& get_instance();
        
        require_once($this->_ci->config->item('libs_path')."/ezpdo.1.1.6/ezpdo_runtime.php");

        // epLoadConfig(APPPATH.'/config/ezpdo.xml');
        $this->m = epManager::instance();
        
        // set the DSN as specified in config/ci-ext.php
        $this->m->setConfigOption('default_dsn', $this->_ci->config->item('default_dsn'));
        // set other config options
        $this->m->setConfigOption('source_dirs', APPPATH.'/models/classes/');
        $this->m->setConfigOption('compiled_dir', APPPATH.'/tmp/models/');
        $this->m->setConfigOption('log_file', APPPATH.'/tmp/ezpdo.log');
        $this->m->setConfigOption('force_compile', $this->_ci->config->item('force_compile'));
    }
}

?>